<?php
namespace app\admin\controller;

use app\api\service\serv\ApiLogService;
use think\facade\View;
use app\Request;

/***
 * Class Log
 * @package app\admin\controller
 * @Author Vee7
 * @Date 2021/12/22
 * @Time 14:07
 * @Description 接口的日志
 */
class ApiLog extends ViewBaseController
{
    public function index()
    {
        return View::fetch('index');
    }

    /***
     * @param Request $request
     * @param ApiLogService $log
     * @return \think\response\Json
     * @Author Vee7
     * @Date 2021/12/22
     * @Time 14:02
     * @Description 日志列表获取接口
     */
    public function getApiLogListJson(Request $request,ApiLogService $log)
    {
        $page = $request->param('page');
        $limit = $request->param('limit');
        return layuiJson(0,'日志列表获取成功',$log->getApiLogListPage($page,$limit,'id','desc'),$log->getApiLogListCount());
    }

    /***
     * @param Request $request
     * @param ApiLogService $log
     * @return \think\response\Json
     * @Author Vee7
     * @Date 2021/12/22
     * @Time 14:02
     * @Description 日志删除接口
     */
    public function del(Request $request,ApiLogService $log)
    {
        $idArray = $request->param('idArray');
        $bool = $log->delApiLogList($idArray);
        if(!$bool)
        {
            $result = layuiJson(1,'删除失败');
            return $result;
        }
        return layuiJson(0,'删除成功',$idArray);
    }

}
